<?php

namespace App\Http\Controllers\Api;

use App\TalentsSystemOrder;
use Illuminate\Http\Request;

class TalentsOrderController extends BaseController
{
    public function index(Request $request)
    {
        $orderBy = $request->order_by ? $request->order_by : 'id';
        $orderType = $request->order_type ? $request->order_type : 'desc';
        $pageSize = $request->page_size ? $request->page_size : $this->pageSize;
        $lists = TalentsSystemOrder::orderBy($orderBy, $orderType)->with(['user']);
        if ($request->get('order_number')) {
            $lists = $lists->where('order_number', $request->order_number);
        }
        if ($request->get('pay_status')) {
            $lists = $lists->where('pay_status', $request->pay_status);
        }
        return $lists->paginate($pageSize);
    }
}
